package com.company.设计模式.单例模式.result;

/**
 * @author uguoy089
 * @Description:
 * @Date: 2021/5/11 10:48
 *
 * 各种情况相对应的返回数据模板（工具类）
 */

public class ResUtils {
    public static Result success() {
        Result<Object> result = new Result<>();
        result.setCode(Status.SUCCESS.getCode());
        result.setMsg(Status.SUCCESS.getMsg());
        return result;
    }

    public static Result failure() {
        Result<Object> result = new Result<>();
        result.setCode(Status.FAILURE.getCode());
        result.setMsg(Status.FAILURE.getMsg());
        return result;
    }

    public static Result success(Object data) {
        Result<Object> result = new Result<>();
        result.setCode(Status.SUCCESS.getCode());
        result.setMsg(Status.SUCCESS.getMsg());
        result.setData(data);
        return result;
    }

    public static Result failure(Object data) {
        Result<Object> result = new Result<>();
        result.setCode(Status.FAILURE.getCode());
        result.setMsg(Status.FAILURE.getMsg());
        result.setData(data);
        return result;
    }

    public static Result unknown_error() {
        Result<Object> result = new Result<>();
        result.setCode(Status.UNKNOWN_ERROR.getCode());
        result.setMsg(Status.UNKNOWN_ERROR.getMsg());
        return result;
    }

    public static Result user_not_exist() {
        Result<Object> result = new Result<>();
        result.setCode(Status.USER_NOT_EXIST.getCode());
        result.setMsg(Status.USER_NOT_EXIST.getMsg());
        return result;
    }

    public static Result user_is_exists() {
        Result<Object> result = new Result<>();
        result.setCode(Status.USER_IS_EXISTS.getCode());
        result.setMsg(Status.USER_IS_EXISTS.getMsg());
        return result;
    }

    public static Result data_is_null() {
        Result<Object> result = new Result<>();
        result.setCode(Status.DATA_IS_NULL.getCode());
        result.setMsg(Status.DATA_IS_NULL.getMsg());
        return result;
    }
}
